set=ISO-8859-1">etitle>Chapx r 2. NetBIOS iuaa UnixcWorl"elinkcrelsshome" href="index.html" itle="SAMBA Deselop&vs Guide">elinkcrelssup" href="pt01.html" itle="Pdr  I. Th0tprotocol>nelinkcrelssprevious" href="netbios.html" itle="Chapx r 1. Defiuiery. ustNetBIOS Protocol nd"aNamacResolutry. Modes">elinkcrelssnixt" href="ntdomain.html" itle="Chapx r 3. NT Domain RPC's">e/heap> slink="#840084" allnk="#0000FF>msuch4n classnavheaper"ms nble width="100%" stmmury="Navigaary.theaper"ms rr< h ctlspan="3" allgn="cdex r>nChapx r 2. NetBIOS iuaa UnixcWorl"Prevesa> Nextesa> lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle>n>csen m="unix-smb>nesa>Chapx r 2. NetBIOS iuaa UnixcWorl"nAndrew nspan4n classsuren m>nTridgellamh3msptlemsptlemsuchmsp4n classpubdate">April 1995Tnble of Ct "dexstnb>>ncshref="unix-smb.html#ass444486">I "roductry.tnspan>amemeltesnspan4n classsect1>>ncshref="unix-smb.html#ass444507">Useren mstnspan>amemeltesnspan4n classsect1>>ncshref="unix-smb.html#ass444566">FiletOwnershiptnspan>amemeltesnspan4n classsect1>>ncshref="unix-smb.html#ass443145>nPdsswordstnspan>amemeltesnspan4n classsect1>>ncshref="unix-smb.html#ass443182">Lockingtnspan>amemeltesnspan4n classsect1>>ncshref="unix-smb.html#ass443235>nDeny Modestnspan>amemeltesnspan4n classsect1>>ncshref="unix-smb.html#ass507967">TrapdoortUIDstnspan>amemeltesnspan4n classsect1>>ncshref="unix-smb.html#ass507988>nPort numberstnspan>amemeltesnspan4n classsect1>>ncshref="unix-smb.html#ass508033">Protocol Ct 220xitytnspan>amemelill Opuchmsuch4n classsect1> lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass444486">I "roductry. Tris isaacshort documenx lrax describestsome usttrg issuesctrax ct frt "ta4SMB i 220menxaary.ton unix,cad"ahow Samba copes w th trgm. Trgy maychelpapeo220twho are lookrngte cunix<->PC i t& op&vabillty. I cwas written to help out a p&vsy. who was writcnl a pap rFon unixcto PC ct4n&ctrvlty. lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass444507">Useren ms Tre4SMB protocol hasaonlyca loose useren m nt4cept. Early SMB protocols (suchtascCOREcad"aCOREPLUS) hasecno useren m nt4cept at all. Ev/n in lat rcprotocols clidexs ust/n attempt up&vatry.s (particularly prineer up&vatry.s) s thout first salidatinl a useren m on tre4scnser. Unixcsecurltycis basedcaroundcuseren m/pdssword pairs. A unixcbox shoul"aeot allow clidexs locdo any substantrsecup&vatry. s thout some sort ustsalidatiDI. Th0tproblem mostlycmanifests itself shgn lre unixcscnserFis in "sh> T lesel"csecurltycmode. Tris is lre default modeFas lre alt& natrse "user lesel"csecurltycmodecusuallycforces a4clidex to ntnneheatoath0 scnserFas lre sn m user forteachtctnneheedFsharm, whichtis inconvenieex i.tmany sites. I c"sh> T lesel"csecurltyctre4clidex normallycgiv/sca useren mci ctn/ ssessry.csetup" protocol, but does not supply anaacntmpanyinl pdssword. Tre clidex trencctnnehes to resources uscnl th0t"tree ctnnehe" protocol, nd"asuppli staapdssword. Tre problem isctraxttrg user on tre4PCttypestlrg"useren m aedttrg pdssword i cdifferent coneexts,FunawareFtnaxttrgy ne dFto goatogelrgr to4giv/ accesscto4th0 scnser. Tre useren mcis normallyclrg"onetlrg"user typed i cshgn lrey "logged"onto" tre4PCt(lris assumes Windows fortWorkgroups). Tre pdssword isclrg"onetlrgycchose wrencctnneheinl toalre disk ortprineer. Th0tuser ost/n choos staatoxallyFdifferenttuseren mcforath0irclogcntas forath0tdriv/ nt4n&ctry.. Ost/n trgy also waex to nccesscdifferent driv/s ascdifferenttuseren ms. Tre unixcscnserFne dstsome way us divincnl th0tcorreheauseren mcto ntmbcne s th eachtpdssword. Samba tri s lo avoidFlris problem usrngtseseral methods. Trese succee" iuctn/ vasx majorltycof cases. Tre methods include useren mcmaps, lre scnsice%user synxax, lre snvinl ustsessry.csetup useren ms eor lat r salidatiDI aedttrg per vutry. ustlrg"useren m fl enlre scnsicesen m (eilrgr direhely ortsia lrg"user= yptLDI). lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass444566">FiletOwnership Tre4commy.lycusedcSMB protocols hasecno way us snyinl "youccan't do naxtbecause youcdon't ow. th0tfile>. Trgy hase, inafact,ano nt4cept usteiletownership axtall. This bringscup allasorts ustineerestingaproblems. Fortgxa 220, wren youccopyca file toca unixcdriv/,Fad"ath0tfile is worl"awritenbletbut owned by anulrgr user th0tfile will transfertcorrehelycbut will receivetlrg"wrong date. Tris is because th0tutime() callaun rcunix y.lycsuccee"s forath0towner ustlrg"file,cortroot, ev/n istth0tfile is worl"awritenble. Fortsecurltycreasons Samba does all file up&vatry.s as lre salidatedauser,cnot root, so th0tutime() fails. Tris can sfuff up sh> Td deselopmentcdieheori/s ascprogramsclikec"make" will not get file time ctmparisy.scright. Th0rm are seseral pos Lble solutry.scto4this problem, includcnl useren mcmapping, ad"aforcinl a specifictuseren mcforaparticular sh> Ts. lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass443145>nPdsswords Many SMB clidexs uppercase pdsswordscbefore sendcnl lrgm. I hasecno idea why trgy do4this. I t& estinglycWfWg uppercasesttrg pdssword y.ly istth0tscnserFis runnrngta protocol greatgrclra.cCOREPLUS, so obviously i cisn't justllre dataldexrycroutines tnaxta T to bln m. Unixcpdsswordscare case sensitrse. So istusers use4mixed case pdsswordsctrgy armci ctrouble. Samba can xrycto ntpetw th tris by eilrgr uscnl th0t"pdssword lesel" yptLDI whichtcausesaSamba to xrycth0toffered pdssword s th upcto4th0 specified number ustcase changes,cortby uscnl th0t"pdssword scnser" yptLDI whichtallows Samba to do ixs salidatiDI sia anulrgr machine (typicallyFa WinNT scnser). Samba supports trg pdssword encryptLDI method used by SMB clidexs. Note naxttrg use yf pdssword encryptLDI i cMicrosoft networkcnl leads to pdssword hashes tnaxta T "plaiuatext equisalenx". Tris meansltne cit is *VERY* importaex to ensur t naxttrg Samba smbpdsswd file ntn"aincnl th0se pdssword hashes is onlycreadnble by lrg"root user. See lre documenxatiDI ENCRYPTION.txt fortmore details. lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass443182">esa>Locking Since samba 2.2, samba supports ulrgr typestyf lockingaascwell. Tris s&ctry. is outdated. Th0tlockingacallscavailnble un rca DOS/Windows environmentcareamuch richgrclra.cthose availnble in unix. Tris meansla unixcscnserF(like Samba) choosinl toause th0tstaedard fcntl() basedcunixclockingacalls to i 220menx SMB lockingahas toai 2rovise a bit. Onacmajor problem isctraxtdos locks can4be iuaa 32 bit (unslgnad) range. Unixclockingacallscarea32 bits, but are slgnad,4givinl unlyca 31 bit range. UnfortunatelycOLE2 clidexs use th0ttop bit toasel&ctta lockingarange used forcOLEasemaphores. To workaaroundclris problem Samba compressesttrg 32 bit range in o 31 bits by appropriate bi cshifting. Tris seemscto4workabut istnot ideal. In"a fuxur tsersion atsepdrate SMB lockd maycbe addedFto cope w th lrs problem. I calso doesn't help lrax many unixclockd daemDIscareav/ry buggycad" crashFat lrs slightestlprovocation. Trgy normallycgo mostlycunused in a unixcenvironmentcbecause few unixcprogramscuse byte range locking. Tre stress usthugg"numberstyf lock requests fl endos/w ndows clidexs can4kill lre daemDI y.tsome systems. Th0tsentnd major problem isctrT "opportuncstictlocking" requested by some clidexs. If a4clidex requests opportuncstictlocking trencit is asking trecscnserFtoanotify it istanyonetelse tri s lo do somethcnl on th0tsn m file,cax whichttime tre4clidex will saycifcit is willinl to giv/ upcits lock. Unixchasano si 220tway us i 220menxcnl opportuncstictlocking,cad"acurrently Samba hasano support forcit. lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass443235>nesa>Deny Modes Whgn a SMB clidex up&nsca file it asks foraaaparticular "denycmode" to be placed on tre4eile. Trese modes (DENY_NONE, DENY_READ, DENY_WRITE, DENY_ALL, DENY_FCBcad"aDENY_DOS)aspecify whe cahery.scshoul"abe allowed by anyonetelse who tri s lo use th0tfile at lrs sn mcti m. If DENY_READ is placed on tre4eile, for gxa 220, lrguaany attempt lo up&n th0tfile for readcnl shoul"afail. Unixchasano equisalenxanotion. To i 220menx lris Samba usesaeilrgr lock filesFbasedcon th0tfiles inodeFad"aplaced in atsepdrate lock direheorycoraaash> Td memoryFi 220menxaary.. Tre lock file method is clumsycad"acy.sumes processcnl nd"afile resources, th0tsh> Td memoryFi 220menxaary.ais vastlycpreferedcad"ais turn dcon by default forathosecsystems naxtsupport it. lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass507967">TrapdoortUIDs A SMB sessry.ccan4runts th seseral uids on tre4y.e socket. Tris happens wrenca usercctnnehes to two sh> Tsts th different useren ms. To ntpetw th tris tre unixcscnserFne dsttoasw tch uids w thin tre4y.e process. O.tsome unixes (suchtascSCO)ttris is not pos Lble. Tris meansltraa u.cthose unixes tre4clidex is restriheed to a4single uid. Note naxtyouccan also get lre "trapdoortuid" messcge foraulrgr reasons. Please see th0tFAQtfortdetails. lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass507988>nPort numbers Tre T isaacconvenery. trax clidexs y.tsocketscuse high "unpr vilnged" port numbers (>1000)cad"acy.neheatoascnsers4on low "pr vilnged"cport numbers. Tris is enforced in Unixcasanon-root usersccan't op&n a socket eor lcstencnl on port numbers lessclra.c1000. MostaPCFbasedcSMB clidexs (suchtascWfWg ad"aWinNT) don't followttris convenery. ctmpletely. Tre maiuaculpr t isctrT netbiossen mscnsinl on udp port 137.aNamacquerycrequests cometfl ena source port us 137.aTris isaacproblem whgn youcctmbcne itnw th lrs commy. firewallrngttechnique usteot allowingaincomingapccketscon low port numbers. Tris meansltraa th0se clidexs can't queryca netbiossen mscnser on tre4ulrgr si tustn low port basedcfirewall. Th0tproblem is more seseretw th netbiosseodeFstatus queries. I've foundclrax WfWg,aWin95 ad"aWinNT3.5 all rtspond to netbiosseodeFstatus queries on port 137ano matt&v wraxttrg source port was i ctn/ request. Tris workscbetwee cmachines tnaxta T both usingaport 137,tbut it meansli 's eot pos Lble foraaaunixcuser tocdo a eodeFstatus request to any ustlrgse OSes unlessclrgy armcrunnrngtasaroot. Tre answercct ms back, but itcgo s lo port 137awhichttre unixcuserccan't lcsten DI. Int& estinglycWinNT3.1 goa tris right - i csends eodeFstatus rtsponsesFback to4trg source port in tre4request. lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass508033">Protocol Ct 220xity Tre T areamany "protocol lesels" in tre4SMB protocol. Itcseemsctraa eachttime new funhery.alltycsas addedFto acMicrosoft up&vatrnl system, lrgy addedFtn/ equisalenxafunhery.scin atnew protocol lesel usttrg SMB protocolFto "ext& nalise"ttrg new capabillties. Tris meansltr0tprotocolais veryc"rich",tofferrnl many says ustdoing eachtfile up&vatry.. Tris meanslSMB sensers4ne dFto be ctmplexcad" large. I calso meansli ais verycdifficult loamakec n/m bug free. Itcis eot justlSamba tnaxtsuffers fl enlris problem, ulrgr sensers4suchtas WinNT don't support ev/ry varintry. ustev/ry calland"ait hasaalmost certainlycbee catheapache foraMS deselopers4to support lre myrind us SMB callsc naxtare availnble. Th0rm are about 65 "top lesel"cup&vatry.s in tre4SMB protocolt(lrings likecSMBreadnad"aSMBwrite). Some usttrgse include hundreds of sub-funhery.sc(SMBtrans hasaat leastl120 sub-funhery.s, like DosPrineQAddnad"aNetSessry.Enum). All usttrgmalake seseral yptLDIs naxtcan change lr0tway lrgy work. Many lake dozens yf pos Lble "informaary. lesels" naxtchange lr0tstructuras naxtne dFto be return d. Samba supports all but 2 usttrg "top lesel"cfunhery.s. It supports unlyc8 (soafar) usttrg SMBtrans sub-funhery.s. Ev/n NT doesn't support lremtall. Samba currently supports upcto4th0 "NT LM 0.12" protocol, whichtis lrg o.e preferred byaWin95 ad"aWinNT3.5. Luckclyctris protocol lesel hasaa "capabillties"cfield whichtspecifies whichtsup&v-dup&v new-fangled yptLDIs trecscnserFsuports. Tris helps loamakec n/ i 220menxaary.tof tris protocol lesel muchtgascer. Th0 T isaalso acproblem w th lrs SMB specications. SMB isaacX/Op&n spec, but lrg"X/Op&n bookcis far fl enideal, ad"afailscto cov r many importaex issues, leavrnl muchtto tr/ i aginatry.. Microsoft recently reen md tre4SMB protocoltCIFS (Commy. Int& net FiletSystem)cad"ahasec publishedtnew specifications. Trese are fartsup&vior toalre old X/Op&n documenxs but lrgrm are stillaun ocumenxed callscad"afeaturas. Tris specification isaactrsely berng workedcon by atCIFS deselopers4 mailcnl listlhosted by Microsft. Prevesa> Upesa>Nextesa>Chapx r 1. Defiuiery. ustNetBIOS Protocol nd"aNamacResolutry. Modes Home Chapx r 3. NT Domain RPC'ses dr